﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;

using DemoExtNet.BusinessObject.BusinessEntities;
using Ext.Net;

namespace DemoExtNet.PhanQuyen
{
    public partial class PhanQuyen : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           if (!Page.IsPostBack)
           {
               BindData_NhomQuyenByToChuc();

            }
        }

        public void BindData_NhomQuyenByToChuc()
        {
            var oQUNhomQuyenByToChuc = new QUNhomQuyenByToChuc();
            storeQUNhomQuyenByToChuc.DataSource = oQUNhomQuyenByToChuc.GetAll();
            storeQUNhomQuyenByToChuc.DataBind();
        }

            

        public void GetNguoiDungByToChuc(int pToChucId)
        {
         
        }

        private void CreateNodeLv1()
        { 
        
        }

        private void CreateNodeLv2()
        {

        }

        private void CreateNodeLv3()
        {

        }

        public void UpdateGridNguoiDung()
        {
            //ucQUNhomQuyenByToChuc_Detail.UpdateGridNguoiDung();
        }

        public void ShowDialog_QUNguoiDung(int pNhomQuyenByToChucId)
        {
           // ucQUNguoiDung.ShowDialogAddNguoiDungInToChuc(pNhomQuyenByToChucId);
        }

        [DirectMethod]
        public void ShowDialog_QUNhomQuyenByToChuc_Detail(int pQUNhomQuyenByToChucId)
        {
            ucNhomQuyenByToChuc.ShowDetailDialog(pQUNhomQuyenByToChucId);
        }
        [DirectMethod]
        public void ShowDialog_QUNhomQuyenByToChuc_Edit(int pNhomQuyenByToChucId, string pTenNhomQuyenByToChuc, string pGhiChu)
        {
            ucNhomQuyenByToChuc.ShowEditDialog(pNhomQuyenByToChucId);
        }

        protected void ShowDialog_QUNhomQuyenByToChuc_AddNew(object sender, DirectEventArgs e)
        {
            //ucQUNhomQuyenByToChuc_Edit.ShowAddNewDialog();
            ucNhomQuyenByToChuc.ShowAddNewDialog();
        }

        [DirectMethod]
        public void NhomQuyenByToChuc_Delete(int pNhomQuyenByToChucId)
        {
            QUNhomQuyenByToChuc oItem = new QUNhomQuyenByToChuc();
            oItem = oItem.GetById(pNhomQuyenByToChucId);
            //if (oItem.QUNhomQuyenByToChuc_NguoiDungs.Count > 0 || oItem.QUNhomQuyenByToChuc_ToChucs.Count > 0)
            //{
            //    X.Msg.Show(new MessageBoxConfig
            //    {
            //        Title = "Error",
            //        Message = "Không thể xóa record này.",
            //        Buttons = MessageBox.Button.OK,
            //        Icon = MessageBox.Icon.ERROR
            //    });
            //    return;
            //}
            oItem.Delete();
            BindData_NhomQuyenByToChuc();
        }
    }
}
